import Mock from 'mockjs'
import store from '@/store'
let res = [
    {
        resid:1,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:2,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:3,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:120,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:4,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:5,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:70,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:6,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:7,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:8,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:9,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:0
    },
    {
        resid:10,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:0,
        isuse:0
    },
    {
        resid:11,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:12,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:13,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:14,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:15,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:0,
        isuse:1
    },
    {
        resid:16,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:0,
        isuse:1
    },
    {
        resid:17,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:18,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:19,
        resname:"MHK考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
    {
        resid:20,
        resname:"英语四级考试",
        path:"./public/mhk/651651.jpg",
        spendtime:60,
        uploadtime:"2018-1-29",
        isdownload:1,
        isuse:1
    },
];
Mock.mock(/\/file\/query/, 'post', options => {
    // dataListForGroup.extra = extraData.extra.slice(1)
    // return dataListForGroup
    return res;
})

Mock.mock(/\/file\/deleteBySelected/, 'post',options => {
    const result = JSON.parse(options.body).resids;
    if (result instanceof Array) {
        for (let i = 0; i < res.length; i++) {
          for (let j = 0; j < result.length; j++) {
            if (result[j] === res[i].resid) {
              res.splice(i, 1);
            }
          }
        }
      } else {
        res = res.filter(item => item.resid !== result)
      }
      return {
        code: 0,
        msg: "删除成功",
        result
      };
})
